
package com.work.mvc.controler;

import com.vaadin.data.*;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.Component;
import com.work.jaxb.menu.XmlPropertyEnum;
import com.work.mvc.View;
import com.work.mvc.view.panels.*;
import com.work.mvc.view.tree.TreeController;

public class TreeReportsControler extends TreeController {

	private static final long serialVersionUID = 3772156191389810071L;

	public TreeReportsControler() {}

	@Override
	public void valueChange(ValueChangeEvent event)
	{
		if (event.getProperty().getValue() != null) {
			Property<?> property = getTree().getItem(event.getProperty().getValue()).getItemProperty(XmlPropertyEnum.NAME.getValue());
			String selectedOptionName = String.valueOf(property.getValue());
			
			Component content = null;
			if ("Nadgodziny".equals(selectedOptionName)) {
				content = ContentFactory.getInstance().createContent(ContentPanelsEnum.REPORT_OVERTIME_PANEL);
			} else if ("Urlopy".equals(selectedOptionName)) {
				content = ContentFactory.getInstance().createContent(ContentPanelsEnum.REPORT_LEAVE_PANEL);
			}
			ContentPanel.changeContent(content);
		}
	}

	@Override
	public View getView()
	{
		return null;
	}
}
